package com.example.ediableview

import android.app.AlertDialog
import android.content.DialogInterface
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.FrameLayout
import androidx.annotation.RequiresApi

class MainActivity : AppCompatActivity() {

    @RequiresApi(Build.VERSION_CODES.R)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val editText = findViewById<EditText>(R.id.edit_query1)

        editText.setOnClickListener() {
            editText.setText("")
        }

        editText.setOnFocusChangeListener() { _: View, hasFocus: Boolean ->
            if (!hasFocus) {
                AlertDialog
                    .Builder(this)
                    .setTitle("输入提示框")
                    .setIcon(R.mipmap.ic_launcher)
                    .setMessage("您输入的内容为：" + editText.text)
                    .setPositiveButton("确定") { _: DialogInterface, _: Int ->
                        Log.i("提示","6666")
                    }
                    .setNegativeButton("取消") { _: DialogInterface, _: Int ->
                        Log.i("提示","6666")
                    }.show()
            }
        }
    }
}
